"""
1）过滤出长度大于3的人名
name = ['tom','lily','jacks','Pe','Steven']
2）得到嵌套列表中每个列表的最后一个元素
list1 = [[1,2,3],[4,5,6],[7,8,9]]
3）员工工资>5000的人加200，否则加500
dict1 = {'name':'张三','salary':6000}
dict2 = {'name':'李四','salary':8000}
dict3 = {'name':'王五','salary':4000}
dict4 = {'name':'吴二','salary':3000}
list2 = [dict1,dict2,dict3,dict4]
4）找到分数60分以下的人姓名
scores = {
      "Rick Sanchez": 70,
      "Morty Smith": 35,
      "Summer Smith": 82,
      "Jerry Smith": 23,
      "Beth Smith": 98
    }
"""
name = ['tom', 'lily', 'jacks', 'Pe', 'Steven']
li1 = [i for i in name if len(i) > 3]
print(li1)

list1 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
li2 = [i[-1] for i in list1]
print(li2)

dict1 = {'name': '张三', 'salary': 6000}
dict2 = {'name': '李四', 'salary': 8000}
dict3 = {'name': '王五', 'salary': 4000}
dict4 = {'name': '吴二', 'salary': 3000}
list2 = [dict1, dict2, dict3, dict4]
# i是字典，比如dict1 = {'name': '张三', 'salary': 6000}
# 取出工资i['salary']或i.get('salary',0)
li3 = [(i['name'], i['salary'] + 200) if i['salary'] > 5000 else (i['name'], i['salary'] + 500) for i in list2]
print(li3)

scores = {
    "Rick Sanchez": 70,
    "Morty Smith": 35,
    "Summer Smith": 82,
    "Jerry Smith": 23,
    "Beth Smith": 98
}
dict1 = {k: v for k, v in scores.items() if v < 60}
print(dict1)
